package ru.drugdrugu;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

import ru.drugdrugu.bean.PCBean;
import ru.drugdrugu.bean.POSTBean;

public class runJpa {
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		EntityManagerFactory emf = Persistence
				.createEntityManagerFactory("PCBean");
		EntityManager em = emf.createEntityManager();
		em.getTransaction().begin();
		PCBean pcBean = new PCBean();
		pcBean.setName("Alexander");
		pcBean.setSurnane("Шек");
		pcBean.setSecondName("Владимирович");
		em.persist(pcBean);

		POSTBean post = new POSTBean();
		post.setPc(pcBean);
		em.persist(post);

		em.flush();
		em.getTransaction().commit();
		em.close();
		emf.close();
	}
}
